<?php
class TestModule extends CWebModule
{
    public $assetsUrl;

    public function init ()
    {
        // this method is called when the module is being created
        // you may place code here to customize the module or the application
        
        // 导入相关文件
        $this->setImport(
                array(
                        'test.models.*',
                        'test.components.*'
                ));
        // 配置相关组件参数
        Yii::app()->setComponents(
                array(
                        'errorHandler' => array(
                                'class' => 'CErrorHandler',
                                'errorAction' => 'admin/default/error'
                        ),
                        'urlManager'=>array(
                        		'urlFormat'=>'get',
                        		'showScriptName'=>false,
                        		/* 'rules'=>array(
                        		 '<controller:\w+>/<id:\d+>'=>'<controller>/view',
                        				'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
                        				'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
                        		), */
                        )
                ));
        // 设置资源文件发布路径
        $this->assetsUrl = Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias('test.assets'), true, - 1, true);
        //Yii::app()->clientScript->registerCoreScript('jquery',CClientScript::POS_HEAD);
    }

    public function beforeControllerAction ($controller, $action)
    {
        if (parent::beforeControllerAction($controller, $action)) {
            // this method is called before any module controller action is
            // performed
            // you may place customized code here
            return true;
        } else
            return false;
    }
}
